<?php
$this->breadcrumbs=array(
	tt('Users'),
);

$this->menu=array(
	array('label'=>tt('Create User'), 'url'=>array('create')),
	array('label'=>tt('Manage User'), 'url'=>array('admin')),
);

$this->h1 = tt('Users');

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('user-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<div class="clear">
	<?php
		echo CHtml::htmlButton(
				tt('Create user'), 
				array(
					'class'=>'button grey', 
					'onclick'=>'document.location.href="'.Yii::app()->createAbsoluteUrl(
							"/user/admin/default/create").'"'
					)
		);
	?>
	<?php echo CHtml::link(tt('Advanced Search'),'#',array('class'=>'search-button prepend-1')); ?>
</div>


<div class="search-form" style="display:none">
<?php echo $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'user-grid',
	'cssFile'=>Yii::app()->theme->baseUrl.'/css/tables.css',
	'itemsCssClass'=>'item-class',
	'pagerCssClass'=>'pager-class',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		array(
			'name' => 'id',
			'sortable' => true,
			'htmlOptions' => array('class'=>'grid-id-column'),
		),
		
		array(
			'name' => 'active',
			'type' => 'raw',
			'value' => 'Yii::app()->controller->returnStatusHtml($data, "user-grid", 0, 0)',
			'htmlOptions' => array('class'=>'grid-status-column'),
			'filter' => false,
			'sortable' => false,
		),

		array(
			'header' => tt('User'),
			'type' => 'raw',
			'value' => '$data->username',
		),
		
		array(
			'name' => 'email',
			'sortable' => true,
		),
		
		array(
			'name' => 'creationDate',
			'htmlOptions' => array('class'=>'grid-date-column'),
			'sortable' => true,
		),
		
		array(
			'class'=>'CButtonColumn',
			'template'=>'{update}{delete}',
			'deleteConfirmation' => tt('Are you sure you want to delete this user?'),
			'htmlOptions' => array('class'=>'button-column'),
			'buttons' => array(
				'update' => array(
					'imageUrl' => $url = Yii::app()->theme->baseUrl.'/images/icon_edit.png',
				),
				'delete' => array(
					'imageUrl' => $url = Yii::app()->theme->baseUrl.'/images/icon_delete.png',
					'visible' => '$data->id != 1',
				),
			),
		),
	),
));
?>
